package flex.cc.order.manage.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import flex.cc.PublicUtil;
import flex.cc.order.manage.dao.OrderCustomerDao;
import flex.cc.order.manage.dto.order.OrderCustomerEntity;
import flex.cc.order.manage.dto.vo.OrderMainVo;
import flex.cc.order.manage.service.OrderCustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * @author wkangle
 * @className OrderCustomerServiceImpl
 * @description 服务单客户信息表service实现类
 * @time 2021-09-06 15:53:10
 */
@Service("OrderCustomerService")
@Transactional(rollbackFor = Exception.class)
public class OrderCustomerServiceImpl extends ServiceImpl<OrderCustomerDao, OrderCustomerEntity> implements OrderCustomerService {

    @Autowired
    private OrderCustomerDao orderCustomerDao;

    /**
     * @param orderCustomerEntity
     * @return
     * @description 添加一条记录
     * @author wkangle
     * @time 2021/09/08 0008 8:58
     * @exception/throws
     */
    @Override
    public int insert(OrderCustomerEntity orderCustomerEntity) {
        return orderCustomerDao.insert(orderCustomerEntity);
    }

    /**
     * @param params 查询条件
     * @return
     * @description 根据查询条件查询服务单客户
     * @author wkangle
     * @time 2021-09-08 16:19:25
     * @exception/throws
     */
    @Override
    public OrderCustomerEntity getOneByParams(Map<String, Object> params) {
        return orderCustomerDao.getOneByParams(params);
    }

    /**
     * @param orderCustomerEntity
     * @return
     * @description 更新
     * @author wkangle
     * @time 2021-09-12 15:19:36
     * @exception/throws
     */
    @Override
    public int update(OrderCustomerEntity orderCustomerEntity) {
        return orderCustomerDao.update(orderCustomerEntity);
    }

	@Override
	public List<Map<String, String>> querySearchAsyncMobile(OrderMainVo vo) {
		List<Map<String,String>> list = orderCustomerDao.querySearchAsyncMobile(vo);
		return list;
	}

	@Override
	public String queryCustomerByNo(OrderMainVo vo) {
		List<OrderCustomerEntity> list = orderCustomerDao.queryCustomerByNo(vo);
		if(PublicUtil.isNotEmpty(list)) {
			OrderCustomerEntity entity = list.get(0);
			return entity.getUsername();
		}
		return null;
	}
}
